<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script>
        function setCookie(name,value,iDay){//设置cookie的名字、值、截止时间
            var oDate=new Date();
            oDate.setDate(oDate.getDate()+iDay);
           document.cookie=name+'='+value+';expires='+oDate;//给cookie添加内容

        }
        function removeCookie (name) {
            setCookie(name,1,-1);//时间设置为-1,这样就能把不要的删除
        }
//        删除这两个值，看看还剩下什么
        removeCookie('userName');
        removeCookie('password');

        alert(document.cookie);//看一下cookie里面有什么
        setCookie('userName','xiongcheng',100);
        setCookie('password','123456',100);
    </script>
</head>
<body>

</body>
</html>